<!-- 用户列表 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label">用户列表</p>
    <div class="mt10">
      <dxtable
        czWidth="440"
        :dataJson="dataJson"
        :portUrl="portUrl"
        :isshowXz="false"
        :qx="qx"
        :czFun="czFun"
        :formJson="formJson"
        ref="databale"
      >
      </dxtable>
    </div>
  </div>
</template>
<script lang="ts" setup>
import dxtable from "../../components/util/dxtable.vue";
import { dxget, dxpost, qurl, hf, dialog } from "../../util/index";
import { h, ref, reactive } from "vue";
import { NButton } from "naive-ui";
import expenseCalendar from "./list.vue";
const showModal = ref(false);
const openid = ref();
const initeer = () => {
  databale.value.initDataExpose();
};
const databale = ref();
// 弹窗公用该列表
let dataJson = reactive([
  {
    title: "头像",
    key: "headimgurl",
    render(row) {
      return h("img", { class: "dsfsdtrtr", src: row.headPortrait });
    },
  },
  {
    title: "昵称",
    key: "name",
    search: true, // 是否在搜索栏展示
  },
  {
    title: "电话号码",
    key: "phone",
    search: true, // 是否在搜索栏展示
  },

  {
    title: "登录ip",
    key: "ip",
  },
  {
    title: "所在城市",
    key: "address",
  },
  {
    title: "金币余额",
    key: "balance",
  }, {
    title: "真实姓名",
    key: "zsnanme",
  },  {
    title: "身份证号码",
    key: "IdCard",
  },   {
    title: "账号状态",
    key: "islahei",
    render(row){
      return  row.islahei =="1"?'正常':'已拉黑'
    }
  },
]);
const Userid = localStorage.id;
let portUrl = "dxgjAdmin/wxcharUser?Applicationid=" + Userid;
const qx = {
  DeletePermissionID: "xinxi100userListdel", //删除
  EditPermissionIdentifier: "ArticlePublishingwxcharUserbj222", // 编辑
  NewPermissionIdentifier: "ArticlePublishingwxcharUserxz", // 新建
  ViewPermissionID: "ArticlePublishingwxcharUserck", // 查看
};
let formJson = reactive([
  {
    title: "头像",
    key: "headPortrait",
    type: "img",
  },
  {
    title: "昵称",
    key: "name",
    type: "input",
    search: true, // 是否在搜索栏展示
  },
  {
    title: "phone",
    key: "phone",
    type: "input",
    search: true, // 是否在搜索栏展示
  },
  {
    title: "金币余额",
    key: "balance",
    type: "number",
  },
]);

const czFun = {
  fun: (row) => {
    const userType = row.userType;
    return [
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {
            const jxcxdf = await dialog("确认拉黑此用户吗？");
            if (jxcxdf == 1) {
              await dxpost(
                "dxgjAdmin/wxcharUser",
                { id: row.id, islahei: row.islahei==1?2:1 },
                "put"
              );
              window.$message.success("操作成功！")
              initeer()
            }
          },
        },
        row.islahei=='1'?"拉黑":'解除拉黑'
      ),h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {
            hf('xinxi100diezhigl?openid='+row.openid)
          },
        },
        '帖子'
      ),h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {
            const jxcxdf = await dialog("确认此操作吗？");
            if (jxcxdf == 1) {
              await dxpost(
                "dxgjAdmin/wxcharUser",
                { id: row.id, isgly: row.isgly==1?2:1 },
                "put"
              );
              window.$message.success("操作成功！")
              initeer()
            }
          },
        },
        row.isgly=='2'?"取消文章发布员":'设为文章发布员'
      ),
    ];
  },
};
</script>
